package jp.sinya.temicontact.utils;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import jp.sinya.temicontact.MyApplication;

/**
 * @author Koizumi Sinya
 * @date 2018/01/11. 21:03
 * @edithor
 * @date
 */
public class FileUtils {
    /**
     * 获取assets文件夹中的文件
     *
     * @param fileName
     * @return
     */
    public static String getFileFromAssets(String fileName) {
        try {
            InputStreamReader inputReader = new InputStreamReader(MyApplication.context.getResources().getAssets().open(fileName));
            BufferedReader bufReader = new BufferedReader(inputReader);

            String line;
            StringBuilder builder = new StringBuilder();

            while ((line = bufReader.readLine()) != null) {
                builder.append(line);
            }

            return builder.toString();

        } catch (Exception e) {
            e.printStackTrace();
        }

        return null;
    }
}